class Triagnle implements IShape {
    Point ptA;
    Point ptB;
    Point ptC;

    public Triagnle(Point ptA, Point ptB, Point ptC) {
        this.ptA = ptA;
        this.ptB = ptB;
        this.ptC = ptC;
    }

    public double getEdgeA() {
        return calculateDistance(ptB, ptC);
    }

    public double getEdgeB() {
        return calculateDistance(ptA, ptC);
    }

    public double getEdgeC() {
        return calculateDistance(ptA, ptB);
    }

    @Override
    public double perimeter() {
        return getEdgeA() + getEdgeB() + getEdgeC();
    }

    @Override
    public double area() {
        double p = perimeter() / 2;
        double a = getEdgeA();
        double b = getEdgeB();
        double c = getEdgeC();
        return Math.sqrt(p * (p - a) * (p - b) * (p - c));
    }

    @Override
    public void draw() {

        System.out.println("Triangle-Perimeter: " + perimeter());
        System.out.println("Triangle-Area: " + area());
    }

    // 计算两点之间的距离
    private double calculateDistance(Point p1, Point p2) {
        int dx = p1.x - p2.x;
        int dy = p1.y - p2.y;
        return Math.sqrt(dx * dx + dy * dy);
    }
}
